<?php

namespace App\Http\Resources;

use App\Models\User;
use Illuminate\Http\Resources\Json\Resource;

class LogResource extends Resource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
//        dd($this->users);
        return [
            'id' => (int)$this->id,
            'logs' => (string)$this->logs,
            'handlers' => (string)$this->handlers,
            'created_at' => (string)$this->created_at,
            'type' =>$this->whenLoaded('users')?$this->whenLoaded('users')->type:'',
            'updated_at' => (string)$this->updated_at
        ];
    }

//    public function findUserType($name)
//    {
//        $model = User::query()->where('name',$name)->first();
//        return $model->type;
//    }
}
